{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="phone" class="layui-input search" name="phone" value="" placeholder="手机号"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="sex" lay-search="" id="sex"  lay-filter="province">
                                <option value="">全部</option>
                                <option value="1" >男</option>
                                <option value="2" >女</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_role" lay-search="" id="user_role"  lay-filter="province">
                                <option value="">全部</option>
                                <option value="1" >有经销商权限</option>
                                <option value="2" >没有经销商权限</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="start" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="开始时间"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="end" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="结束时间"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="province" lay-search="" id="province"  lay-filter="province">
                                <option value="">---- 请选择省 ----</option>
                                {foreach name="province" item="vo"}
                                <option value="{$vo.district_id}" >{$vo.district}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="city" lay-search=""  id="city"  lay-filter="city">
                                <option value="">---- 请选择市 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="district" lay-search=""  id="district"  lay-filter="district">
                                <option value="">---- 请选择区 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('add')}');">-->
                        <!--<i class="fa fa-plus"></i> 添加-->
                        <!--</button>-->
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('unbookAdd')}');" style="margin-left: 5px">-->
                        <!--<i class="fa fa-plus"></i> 添加非图书-->
                        <!--</button>-->

                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                        <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                        <!--&lt;!&ndash;<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>&ndash;&gt;-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-check-circle"></i> 批量上架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-ban"></i> 批量下架</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                        <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                <div class="input-group" >
                <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                </button>
                <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                    <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>
                    <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>
                </ul>
                </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->
                    <!--<script type="text/html" id="imgTpl">-->
                    <!--<img src="{{d.rb_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />-->
                    <!--</script>-->
                    <!--操作模板-->
                    <script type="text/html" id="user_status">
                    {{# if(d.user_status == 1){ }}
                    正常
                    {{# } }}
                    {{# if(d.user_status == 3){ }}
                    冻结
                    {{# } }}
                    </script>

                    <script type="text/html" id="userrole">
                    {{# if(d.user_role == 1){ }}
                    有
                    {{# } }}
                    {{# if(d.user_role == 2){ }}
                    无
                    {{# } }}
                    </script>

                    <script type="text/html" id="user_is_allow_look">
                    {{# if(d.user_is_allow_look == 1){ }}
                    有
                    {{# } }}
                    {{# if(d.user_is_allow_look == 2){ }}
                    无
                    {{# } }}
                    </script>

                    <script type="text/html" id="opeBar">
                        {{# if(d.user_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('down')}','确定冻结吗?')" class="btn btn-primary btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.user_status ==3){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('up')}','确定启用吗?')" class="btn btn-warning btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}
                        {{# if(d.user_role == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('down1')}','确定取消经销商权限吗?')" class="btn btn-warning btn-xs m-r-xs" title="取消">取消经销商</a>
                        {{# } }}
                        {{# if(d.user_role ==2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('up1')}','确定设置经销商权限吗?')" class="btn btn-primary btn-xs m-r-xs" title="设置">设置经销商</a>
                        {{# } }}
                        {{# if(d.user_is_allow_look == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('down2')}','确定取消车辆状态权限吗?')" class="btn btn-warning btn-xs m-r-xs" title="取消">取消车辆状态</a>
                        {{# } }}
                        {{# if(d.user_is_allow_look ==2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('up2')}','确定设置车辆状态权限吗?')" class="btn btn-primary btn-xs m-r-xs" title="设置">设置车辆状态</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.href('{:url('editCarID')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="车联网账号">车联网账号</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Member/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {type:'numbers', width: 70, title: '序号'}
                , {field: 'user_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'user_username', width: 130, title: '昵称', align: 'center'}
                , {field: 'user_car_id', width: 130, title: '车联网ID', align: 'center'}
                , {field: 'user_phone', width: 130, title: '手机号码', align: 'center'}
                , {field: 'address', width: 200, title: '地区', align: 'center'}
                , {field: 'user_time', width: 160, title: '注册时间', align: 'center'}
                , {field: 'user_role', width: 100, title: '经销商权限', align: 'center', templet:"#userrole"}
                , {field: 'user_is_allow_look', width: 120, title: '车辆状态权限', align: 'center', templet:"#user_is_allow_look"}
                , {field: 'user_status', width: 70, title: '状态', align: 'center', templet:"#user_status"}
                , {fixed: 'right', width:340, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('#allidsForOut').val(res.count2);
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>